package stu.aistar.service.Impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import stu.aistar.mapper.SessionMapper;
import stu.aistar.model.pojo.Orders;
import stu.aistar.model.pojo.Session;
import stu.aistar.model.vo.SessionVo;
import stu.aistar.service.ISessionService;

import java.util.List;

@Service
public class ISessionServiceImpl implements ISessionService {
    @Autowired
    private SessionMapper sessionMapper;

    @Override
    public PageInfo<Orders> findSessionsByPage(String page, String pageSize, String userName, String ordersNo, String state) {
        return null;
    }

    @Override
    public List<Session> findByCondition(Session session) {
        return sessionMapper.findByCondition(session);
    }

    @Override
    public Integer save(Session session) {
        return sessionMapper.insert(session);
    }

    @Override
    public List<SessionVo> findAllSessions() {
        return sessionMapper.findAllSessions();
    }

    @Override
    public PageInfo<SessionVo> findSessionsByPage(String page, String pageSize) {
        PageHelper.startPage(Integer.parseInt(page),Integer.parseInt(pageSize));
        List<SessionVo> sessionVos = sessionMapper.findAllSessions();
        PageInfo<SessionVo> pageInfo = new PageInfo<>(sessionVos);
        return pageInfo;
    }

    @Override
    public Integer deleteSession(Integer sid) {
        return sessionMapper.deleteSession(sid);
    }

    @Override
    public Integer updateSession(SessionVo session) {
        return sessionMapper.updateSession(session);
    }
}
